import './gdata.js'
import { app, BrowserWindow } from "electron";
import { createMainWindow } from "./window.js";
import { registerIcpMainHandler } from "./ipcmain-handler/inject.js"
import fixPath from 'fix-path';

fixPath();
app.whenReady().then(() => {
  registerIcpMainHandler(); // 注册ipcHandler（不可重复注册）
  const win = createMainWindow();
  global.app.mainWindow = win; // 挂载全局变量

  app.on("activate", () => {
    // 当应用被激活的时候，但是当前有没有任何窗口展示，那就只能展示主窗口了
    if (BrowserWindow.getAllWindows().length === 0) {
      const win = createMainWindow();
      global.app.mainWindow = win;
    }
  });
});
app.on("window-all-closed", () => {
  if (process.platform !== "darwin") app.quit();
});
